{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "968b93c1",
   "metadata": {},
   "source": [
    "---\n",
    "* 日期：2022-09-14\\week04（周三）\n",
    "* 课程：python\n",
    "* 记录人：zeng\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba527a1e",
   "metadata": {},
   "source": [
    "# 回顾与复习\n",
    "> for+range()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "62005d4f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "for i in range(6):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "59670a73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#创建有序数值(创建自然数)\n",
    "range(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d093d837",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(0,5)) #产生了 5-0个值，默认从0开始 注： 0(start) 5(stop) 每次增长了一个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "bde3990d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(2, 5)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(2,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c95e0cbb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 3, 4]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(2,5)) #产生了 5-2个值， 2(start) 5(stop) 每次增长了一个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "523b9330",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 10, 3)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,10,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "72919ba4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 7]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(1,10,3)) # 2(start) 5(stop) step=3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "4eda160a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index0.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index1.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index2.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index3.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index4.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index5.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index6.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index7.htm\n",
      "该次停留 3 秒\n",
      "https://www.nfu.edu.cn/xxyw/index8.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index9.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index10.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index11.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index12.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index13.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index14.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index15.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index16.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index17.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index18.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index19.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index20.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index21.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index22.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index23.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index24.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index25.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index26.htm\n",
      "该次停留 7 秒\n",
      "https://www.nfu.edu.cn/xxyw/index27.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index28.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index29.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index30.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index31.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index32.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index33.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index34.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index35.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index36.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index37.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index38.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index39.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index40.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index41.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index42.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index43.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index44.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index45.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index46.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index47.htm\n",
      "该次停留 3 秒\n",
      "https://www.nfu.edu.cn/xxyw/index48.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index49.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index50.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index51.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index52.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index53.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index54.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index55.htm\n",
      "该次停留 3 秒\n",
      "https://www.nfu.edu.cn/xxyw/index56.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index57.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index58.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index59.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index60.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index61.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index62.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index63.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index64.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index65.htm\n",
      "该次停留 7 秒\n",
      "https://www.nfu.edu.cn/xxyw/index66.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index67.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index68.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index69.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index70.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index71.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index72.htm\n",
      "该次停留 3 秒\n",
      "https://www.nfu.edu.cn/xxyw/index73.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index74.htm\n",
      "该次停留 7 秒\n",
      "https://www.nfu.edu.cn/xxyw/index75.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index76.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index77.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index78.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index79.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index80.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index81.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index82.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index83.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index84.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index85.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index86.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index87.htm\n",
      "该次停留 7 秒\n",
      "https://www.nfu.edu.cn/xxyw/index88.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index89.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index90.htm\n",
      "该次停留 3 秒\n",
      "https://www.nfu.edu.cn/xxyw/index91.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index92.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index93.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index94.htm\n",
      "该次停留 10 秒\n",
      "https://www.nfu.edu.cn/xxyw/index95.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index96.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index97.htm\n",
      "该次停留 9 秒\n",
      "https://www.nfu.edu.cn/xxyw/index98.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index99.htm\n",
      "该次停留 3 秒\n",
      "https://www.nfu.edu.cn/xxyw/index100.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index101.htm\n",
      "该次停留 8 秒\n",
      "https://www.nfu.edu.cn/xxyw/index102.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index103.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index104.htm\n",
      "该次停留 1 秒\n",
      "https://www.nfu.edu.cn/xxyw/index105.htm\n",
      "该次停留 7 秒\n",
      "https://www.nfu.edu.cn/xxyw/index106.htm\n",
      "该次停留 5 秒\n",
      "https://www.nfu.edu.cn/xxyw/index107.htm\n",
      "该次停留 4 秒\n",
      "https://www.nfu.edu.cn/xxyw/index108.htm\n",
      "该次停留 6 秒\n",
      "https://www.nfu.edu.cn/xxyw/index109.htm\n",
      "该次停留 8 秒\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成某个网站的所有页码的URL队列\n",
    "import random\n",
    "import time\n",
    "南方学院要闻 = \"https://www.nfu.edu.cn/xxyw/index\"\n",
    "页面后缀 = \".htm\"\n",
    "page = 110\n",
    "for i in range(page):\n",
    "    print(南方学院要闻 + str(i) + 页面后缀) # 字符串拼接\n",
    "    random_num = random.randint(1,10)\n",
    "    print(\"该次停留\",random_num,\"秒\")\n",
    "    time.sleep(random_num)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ca21d08",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 总结：for可以执行循环，range决定了循坏体的执行次数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10a12a61",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "\n",
    ">1. random模块\n",
    ">>1.1. random.random()：生成0-1之间的 伪随机数（浮点整数）  \n",
    ">>1.2. random.randint(a,b): 生成a-b的伪随机数 （整数）  \n",
    ">>1.3. random.choice: 随机生成一个序列中的值（非空）  \n",
    ">2. time模块\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "f64b66de",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 1. random\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "f5c0685c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8282901868352402"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "40047b6f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function random:\n",
      "\n",
      "random() method of random.Random instance\n",
      "    random() -> x in the interval [0, 1).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "b06cc924",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'randint' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_10568/918124754.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m## 2. randint\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mhelp\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mrandom\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mrandint\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'randint' is not defined"
     ]
    }
   ],
   "source": [
    "## 2. randint\n",
    "help (random,randint)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "73e43d68",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "71fd703e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "2\n",
      "1\n",
      "6\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b85a66c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "##3. random.choice"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba2c3c2e",
   "metadata": {},
   "source": [
    "# 2.time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c22435da",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "53902b27",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sleep in module time:\n",
      "\n",
      "sleep(...)\n",
      "    sleep(seconds)\n",
      "    \n",
      "    Delay execution for a given number of seconds.  The argument may be\n",
      "    a floating point number for subsecond precision.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.sleep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "8182ddfa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n",
      "world\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "print(\"hello\")\n",
    "time.sleep(3)\n",
    "print(\"world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "314a01e7",
   "metadata": {},
   "source": [
    "# 课本实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b5359935",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14\n",
      "现在秒/时间为偶数\n",
      "等待时间为: 2\n",
      "16\n",
      "现在秒/时间为偶数\n",
      "等待时间为: 3\n",
      "19\n",
      "现在是秒/时间为奇数\n",
      "等待时间为: 4\n",
      "23\n",
      "现在是秒/时间为奇数\n",
      "等待时间为: 3\n",
      "26\n",
      "现在秒/时间为偶数\n",
      "等待时间为: 4\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time,random\n",
    "\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "for i in range(5):\n",
    "    right_this_second = datetime.datetime.today().second\n",
    "    if right_this_second in odds:\n",
    "        print(right_this_second)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "    else:\n",
    "        print(right_this_second)\n",
    "        print(\"现在秒/时间为偶数\")       \n",
    "    wait_time = random.randint(1,5)\n",
    "    print(\"等待时间为:\",wait_time) \n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "be6d77d5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上~~\n",
      "99 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "98 bottles 在啤酒墙上\n",
      "\n",
      "98 bottles 在啤酒墙上~~\n",
      "98 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "97 bottles 在啤酒墙上\n",
      "\n",
      "97 bottles 在啤酒墙上~~\n",
      "97 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "96 bottles 在啤酒墙上\n",
      "\n",
      "96 bottles 在啤酒墙上~~\n",
      "96 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "95 bottles 在啤酒墙上\n",
      "\n",
      "95 bottles 在啤酒墙上~~\n",
      "95 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "94 bottles 在啤酒墙上\n",
      "\n",
      "94 bottles 在啤酒墙上~~\n",
      "94 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "93 bottles 在啤酒墙上\n",
      "\n",
      "93 bottles 在啤酒墙上~~\n",
      "93 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "92 bottles 在啤酒墙上\n",
      "\n",
      "92 bottles 在啤酒墙上~~\n",
      "92 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "91 bottles 在啤酒墙上\n",
      "\n",
      "91 bottles 在啤酒墙上~~\n",
      "91 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "90 bottles 在啤酒墙上\n",
      "\n",
      "90 bottles 在啤酒墙上~~\n",
      "90 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "89 bottles 在啤酒墙上\n",
      "\n",
      "89 bottles 在啤酒墙上~~\n",
      "89 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "88 bottles 在啤酒墙上\n",
      "\n",
      "88 bottles 在啤酒墙上~~\n",
      "88 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "87 bottles 在啤酒墙上\n",
      "\n",
      "87 bottles 在啤酒墙上~~\n",
      "87 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "86 bottles 在啤酒墙上\n",
      "\n",
      "86 bottles 在啤酒墙上~~\n",
      "86 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "85 bottles 在啤酒墙上\n",
      "\n",
      "85 bottles 在啤酒墙上~~\n",
      "85 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "84 bottles 在啤酒墙上\n",
      "\n",
      "84 bottles 在啤酒墙上~~\n",
      "84 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "83 bottles 在啤酒墙上\n",
      "\n",
      "83 bottles 在啤酒墙上~~\n",
      "83 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "82 bottles 在啤酒墙上\n",
      "\n",
      "82 bottles 在啤酒墙上~~\n",
      "82 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "81 bottles 在啤酒墙上\n",
      "\n",
      "81 bottles 在啤酒墙上~~\n",
      "81 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "80 bottles 在啤酒墙上\n",
      "\n",
      "80 bottles 在啤酒墙上~~\n",
      "80 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "79 bottles 在啤酒墙上\n",
      "\n",
      "79 bottles 在啤酒墙上~~\n",
      "79 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "78 bottles 在啤酒墙上\n",
      "\n",
      "78 bottles 在啤酒墙上~~\n",
      "78 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "77 bottles 在啤酒墙上\n",
      "\n",
      "77 bottles 在啤酒墙上~~\n",
      "77 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "76 bottles 在啤酒墙上\n",
      "\n",
      "76 bottles 在啤酒墙上~~\n",
      "76 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "75 bottles 在啤酒墙上\n",
      "\n",
      "75 bottles 在啤酒墙上~~\n",
      "75 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "74 bottles 在啤酒墙上\n",
      "\n",
      "74 bottles 在啤酒墙上~~\n",
      "74 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "73 bottles 在啤酒墙上\n",
      "\n",
      "73 bottles 在啤酒墙上~~\n",
      "73 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "72 bottles 在啤酒墙上\n",
      "\n",
      "72 bottles 在啤酒墙上~~\n",
      "72 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "71 bottles 在啤酒墙上\n",
      "\n",
      "71 bottles 在啤酒墙上~~\n",
      "71 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "70 bottles 在啤酒墙上\n",
      "\n",
      "70 bottles 在啤酒墙上~~\n",
      "70 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "69 bottles 在啤酒墙上\n",
      "\n",
      "69 bottles 在啤酒墙上~~\n",
      "69 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "68 bottles 在啤酒墙上\n",
      "\n",
      "68 bottles 在啤酒墙上~~\n",
      "68 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "67 bottles 在啤酒墙上\n",
      "\n",
      "67 bottles 在啤酒墙上~~\n",
      "67 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "66 bottles 在啤酒墙上\n",
      "\n",
      "66 bottles 在啤酒墙上~~\n",
      "66 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "65 bottles 在啤酒墙上\n",
      "\n",
      "65 bottles 在啤酒墙上~~\n",
      "65 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "64 bottles 在啤酒墙上\n",
      "\n",
      "64 bottles 在啤酒墙上~~\n",
      "64 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "63 bottles 在啤酒墙上\n",
      "\n",
      "63 bottles 在啤酒墙上~~\n",
      "63 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "62 bottles 在啤酒墙上\n",
      "\n",
      "62 bottles 在啤酒墙上~~\n",
      "62 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "61 bottles 在啤酒墙上\n",
      "\n",
      "61 bottles 在啤酒墙上~~\n",
      "61 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "60 bottles 在啤酒墙上\n",
      "\n",
      "60 bottles 在啤酒墙上~~\n",
      "60 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "59 bottles 在啤酒墙上\n",
      "\n",
      "59 bottles 在啤酒墙上~~\n",
      "59 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "58 bottles 在啤酒墙上\n",
      "\n",
      "58 bottles 在啤酒墙上~~\n",
      "58 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "57 bottles 在啤酒墙上\n",
      "\n",
      "57 bottles 在啤酒墙上~~\n",
      "57 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "56 bottles 在啤酒墙上\n",
      "\n",
      "56 bottles 在啤酒墙上~~\n",
      "56 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "55 bottles 在啤酒墙上\n",
      "\n",
      "55 bottles 在啤酒墙上~~\n",
      "55 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "54 bottles 在啤酒墙上\n",
      "\n",
      "54 bottles 在啤酒墙上~~\n",
      "54 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "53 bottles 在啤酒墙上\n",
      "\n",
      "53 bottles 在啤酒墙上~~\n",
      "53 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "52 bottles 在啤酒墙上\n",
      "\n",
      "52 bottles 在啤酒墙上~~\n",
      "52 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "51 bottles 在啤酒墙上\n",
      "\n",
      "51 bottles 在啤酒墙上~~\n",
      "51 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "50 bottles 在啤酒墙上\n",
      "\n",
      "50 bottles 在啤酒墙上~~\n",
      "50 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "49 bottles 在啤酒墙上\n",
      "\n",
      "49 bottles 在啤酒墙上~~\n",
      "49 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "48 bottles 在啤酒墙上\n",
      "\n",
      "48 bottles 在啤酒墙上~~\n",
      "48 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "47 bottles 在啤酒墙上\n",
      "\n",
      "47 bottles 在啤酒墙上~~\n",
      "47 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "46 bottles 在啤酒墙上\n",
      "\n",
      "46 bottles 在啤酒墙上~~\n",
      "46 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "45 bottles 在啤酒墙上\n",
      "\n",
      "45 bottles 在啤酒墙上~~\n",
      "45 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "44 bottles 在啤酒墙上\n",
      "\n",
      "44 bottles 在啤酒墙上~~\n",
      "44 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "43 bottles 在啤酒墙上\n",
      "\n",
      "43 bottles 在啤酒墙上~~\n",
      "43 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "42 bottles 在啤酒墙上\n",
      "\n",
      "42 bottles 在啤酒墙上~~\n",
      "42 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "41 bottles 在啤酒墙上\n",
      "\n",
      "41 bottles 在啤酒墙上~~\n",
      "41 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "40 bottles 在啤酒墙上\n",
      "\n",
      "40 bottles 在啤酒墙上~~\n",
      "40 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "39 bottles 在啤酒墙上\n",
      "\n",
      "39 bottles 在啤酒墙上~~\n",
      "39 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "38 bottles 在啤酒墙上\n",
      "\n",
      "38 bottles 在啤酒墙上~~\n",
      "38 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "37 bottles 在啤酒墙上\n",
      "\n",
      "37 bottles 在啤酒墙上~~\n",
      "37 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "36 bottles 在啤酒墙上\n",
      "\n",
      "36 bottles 在啤酒墙上~~\n",
      "36 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "35 bottles 在啤酒墙上\n",
      "\n",
      "35 bottles 在啤酒墙上~~\n",
      "35 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "34 bottles 在啤酒墙上\n",
      "\n",
      "34 bottles 在啤酒墙上~~\n",
      "34 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "33 bottles 在啤酒墙上\n",
      "\n",
      "33 bottles 在啤酒墙上~~\n",
      "33 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "32 bottles 在啤酒墙上\n",
      "\n",
      "32 bottles 在啤酒墙上~~\n",
      "32 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "31 bottles 在啤酒墙上\n",
      "\n",
      "31 bottles 在啤酒墙上~~\n",
      "31 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "30 bottles 在啤酒墙上\n",
      "\n",
      "30 bottles 在啤酒墙上~~\n",
      "30 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "29 bottles 在啤酒墙上\n",
      "\n",
      "29 bottles 在啤酒墙上~~\n",
      "29 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "28 bottles 在啤酒墙上\n",
      "\n",
      "28 bottles 在啤酒墙上~~\n",
      "28 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "27 bottles 在啤酒墙上\n",
      "\n",
      "27 bottles 在啤酒墙上~~\n",
      "27 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "26 bottles 在啤酒墙上\n",
      "\n",
      "26 bottles 在啤酒墙上~~\n",
      "26 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "25 bottles 在啤酒墙上\n",
      "\n",
      "25 bottles 在啤酒墙上~~\n",
      "25 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "24 bottles 在啤酒墙上\n",
      "\n",
      "24 bottles 在啤酒墙上~~\n",
      "24 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "23 bottles 在啤酒墙上\n",
      "\n",
      "23 bottles 在啤酒墙上~~\n",
      "23 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "22 bottles 在啤酒墙上\n",
      "\n",
      "22 bottles 在啤酒墙上~~\n",
      "22 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "21 bottles 在啤酒墙上\n",
      "\n",
      "21 bottles 在啤酒墙上~~\n",
      "21 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "20 bottles 在啤酒墙上\n",
      "\n",
      "20 bottles 在啤酒墙上~~\n",
      "20 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "19 bottles 在啤酒墙上\n",
      "\n",
      "19 bottles 在啤酒墙上~~\n",
      "19 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "18 bottles 在啤酒墙上\n",
      "\n",
      "18 bottles 在啤酒墙上~~\n",
      "18 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "17 bottles 在啤酒墙上\n",
      "\n",
      "17 bottles 在啤酒墙上~~\n",
      "17 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "16 bottles 在啤酒墙上\n",
      "\n",
      "16 bottles 在啤酒墙上~~\n",
      "16 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "15 bottles 在啤酒墙上\n",
      "\n",
      "15 bottles 在啤酒墙上~~\n",
      "15 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "14 bottles 在啤酒墙上\n",
      "\n",
      "14 bottles 在啤酒墙上~~\n",
      "14 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "13 bottles 在啤酒墙上\n",
      "\n",
      "13 bottles 在啤酒墙上~~\n",
      "13 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "12 bottles 在啤酒墙上\n",
      "\n",
      "12 bottles 在啤酒墙上~~\n",
      "12 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "11 bottles 在啤酒墙上\n",
      "\n",
      "11 bottles 在啤酒墙上~~\n",
      "11 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "10 bottles 在啤酒墙上\n",
      "\n",
      "10 bottles 在啤酒墙上~~\n",
      "10 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "9 bottles 在啤酒墙上\n",
      "\n",
      "9 bottles 在啤酒墙上~~\n",
      "9 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "8 bottles 在啤酒墙上\n",
      "\n",
      "8 bottles 在啤酒墙上~~\n",
      "8 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "7 bottles 在啤酒墙上\n",
      "\n",
      "7 bottles 在啤酒墙上~~\n",
      "7 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "6 bottles 在啤酒墙上\n",
      "\n",
      "6 bottles 在啤酒墙上~~\n",
      "6 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "5 bottles 在啤酒墙上\n",
      "\n",
      "5 bottles 在啤酒墙上~~\n",
      "5 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "4 bottles 在啤酒墙上\n",
      "\n",
      "4 bottles 在啤酒墙上~~\n",
      "4 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "3 bottles 在啤酒墙上\n",
      "\n",
      "3 bottles 在啤酒墙上~~\n",
      "3 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "2 bottles 在啤酒墙上\n",
      "\n",
      "2 bottles 在啤酒墙上~~\n",
      "2 bottles 啤酒~~\n",
      "拿一瓶走~~\n",
      "1 bottle 在啤酒墙上\n",
      "\n",
      "1 bottle 在啤酒墙上~~\n",
      "1 bottle 啤酒~~\n",
      "拿一瓶走~~\n",
      "只剩一瓶酒了，不能给你了！\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 项目3 p44\n",
    "\n",
    "word = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒墙上~~\")\n",
    "    print(beer_num,word,\"啤酒~~\")\n",
    "    print(\"拿一瓶走~~\")\n",
    "    if beer_num == 1:\n",
    "        print(\"只剩一瓶酒了，不能给你了！\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num,word,\"在啤酒墙上\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f62846c",
   "metadata": {},
   "source": [
    "## 课后任务：\n",
    "* 思考：什么是(sequence type)有序的数据\n",
    "* 预习：数值 ，字符串\n",
    "\n",
    ">1. [Numeric Types](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)\n",
    ">2. [Text Sequence Type](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
